/**
 * 
 */
package pms.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Logger;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import pms.dao.KategorieDao;



/** 
 * <p>
 * Controller to generate the Home Page basics to be rendered by a view. 
 * It extends the convenience class AbstractController that encapsulates most 
 * of the drudgery involved in handling HTTP requests. 
 * </p>
 * 
 * <p>
 * ModelAndView contains
 * <ul>
 * <li>title: Will be used as a headline in the resulting view</li>
 * <li>message: Some hints for the user</li>
 * <li>kategorien: A list/set of kategorien</li>
 * <li>command: A command that will be used in the links of the list of "kategorien" (on the view)</li>
 * </ul>
 * The name of the selected view will be: 'list-kategorien.jsp'.
 * </p>
 * 
 * @see KategorieDao
/**
 * @author roman.zaglauer@googlemail.com
 *
 */
public class AlleKategorien extends AbstractController{
	private static Log log = LogFactory.getLog(AlleKategorien.class);
	private KategorieDao kategorieDao;
	
	
	
	/** Getter
	 * @return the kategorieDao
	 */
	public KategorieDao getKategorieDao() {
		return kategorieDao;
	}



	/** Setter
	 * @param kategorieDao the kategorieDao to set
	 */
	public void setKategorieDao(KategorieDao kategorieDao) {
		this.kategorieDao = kategorieDao;
	}



	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest,
			HttpServletResponse httpServletResponse) throws Exception {
		log.info(httpServletRequest.getPathTranslated());
		ModelAndView mv = new ModelAndView();
		mv.addObject("title", "Liste der Kategorien");
		mv.addObject("message", "Alle Kategorien im Notenarchivsystem");
		mv.addObject("kategorien", kategorieDao.findAll());
		mv.addObject("edit", true);
		mv.setViewName("list-kategorien");
		return mv;
	}

}
